import {
	baseUrl
} from "./config.js"

function http(url, methods, data = {},token) {
	if (methods == "get") {
		return new Promise((resolve, reject) => {
			uni.request({
				url: baseUrl + url,
				methods: "get",
				data,
				header: {
				// 	authorization: token,
					"content-type":"application/x-www-form-urlencoded",
				},
				success: res => {
					resolve(res)
				},
				fail: err => {
					reject(err)
				}
			})
		})
	} else if (methods == 'post') {
		return new Promise((resolve, reject) => {
			uni.request({
				url: baseUrl + url,
				methods: "post",
				data,
				header: {
					authorization: token,
					"content-type": "application/x-www-form-urlencoded"
				},
				success: res => {
					resolve(res)
				},
				fail: err => {
					reject(err)
				}
			})
		})
	}
}

export {
	http
}
